package com.ych.controller;

import com.ych.beans.Message;
import com.ych.beans.Product;
import com.ych.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/pipe")
public class ProductController {
    @Autowired
    ProductService service;
    @PostMapping
    public Message addProduct(@RequestBody Product product){
        return service.addProduct(product);
    }

    @DeleteMapping("/{id}")
    public Message deleteProduct(@PathVariable Integer id){
        return service.deleteProduct(id);
    }
    @PutMapping
    public Message updateProduct(@RequestBody Product product){
        return service.updateProduct(product);
    }
    @GetMapping
    public Message selectProduct(@RequestParam Integer pageNo,@RequestParam(required = false) String key){
        return service.selectProduct(pageNo,key);
    }
}
